<template>
  <div class="panel-out">
    <div>
      <h1>小时增量 - 话题：{{currentData.title}}</h1>
    </div>
    <el-row :gutter="40" class="panel-group">
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-new">
            <svg-icon icon-class="eye-open" class-name="card-panel-icon"/>
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              新增浏览量
            </div>
            <count-to :start-val="0" :end-val="currentData.newVisitNum" :duration="1000"
                      class="card-panel-num"/>
          </div>
        </div>
      </el-col>
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-new">
            <svg-icon icon-class="peoples" class-name="card-panel-icon"/>
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              新增关注量
            </div>
            <count-to :start-val="0" :end-val="currentData.newFollowNum" :duration="1000"
                      class="card-panel-num"/>
          </div>
        </div>
      </el-col>
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-new">
            <svg-icon icon-class="edit" class-name="card-panel-icon"/>
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              新增回答量
            </div>
            <count-to :start-val="0" :end-val="currentData.newAnswerNum" :duration="1000"
                      class="card-panel-num"/>
          </div>
        </div>
      </el-col>
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-new">
            <svg-icon icon-class="star" class-name="card-panel-icon"/>
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              新增评论量
            </div>
            <count-to :start-val="0" :end-val="currentData.newCommentNum" :duration="1000"
                      class="card-panel-num"/>
          </div>
        </div>
      </el-col>
    </el-row>

    <el-row :gutter="40" class="panel-group">
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-old">
            <svg-icon icon-class="eye-open" class-name="card-panel-icon"/>
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              历史浏览量
            </div>
            <count-to :start-val="0" :end-val="currentData.visitNum" :duration="1000"
                      class="card-panel-num"/>
          </div>
        </div>
      </el-col>
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-old">
            <svg-icon icon-class="peoples" class-name="card-panel-icon"/>
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              历史关注量
            </div>
            <count-to :start-val="0" :end-val="currentData.followNum" :duration="1000"
                      class="card-panel-num"/>
          </div>
        </div>
      </el-col>
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-old">
            <svg-icon icon-class="edit" class-name="card-panel-icon"/>
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              历史回答量
            </div>
            <count-to :start-val="0" :end-val="currentData.answerNum" :duration="1000"
                      class="card-panel-num"/>
          </div>
        </div>
      </el-col>
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-old">
            <svg-icon icon-class="star" class-name="card-panel-icon"/>
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              历史评论量
            </div>
            <count-to :start-val="0" :end-val="currentData.commentNum" :duration="1000"
                      class="card-panel-num"/>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import CountTo from 'vue-count-to'

export default {
  data() {
    return {
      currentId: "",
      currentData: {}
    }
  },
  components: {
    CountTo
  },
  methods: {
    loadData(id) {
      this.$http("/hot-info/hour?infoId=" + id + "&currentDate=" + this.$store.state.currentDate).then((response) => {
        if (response.data.code !== 0) {
          this.$message.error(response.data.msg);
          return;
        }
        this.currentData = response.data.data;
      });
    }
  },
  mounted() {
    this.currentId = this.$route.query.id;
    if (this.currentId != null) {
      this.loadData(this.currentId);
    }

  }
}
</script>

<style lang="scss" scoped>
.panel-out {
  background-color: aliceblue;
}
.panel-group {
  margin-top: 18px;
  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 48px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .icon-new {
        color: #f4516c;
      }

      .icon-old {
        color: #34bfa3
      }
    }

    .icon-new {
      color: #f4516c;
    }

    .icon-old {
      color: #34bfa3
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}

@media (max-width: 550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
